css: Implement "all" shorthand
authorBenjamin Otte <otte@redhat.com>
Sun, 11 May 2014 01:22:06 +0000 (03:22 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 11 May 2014 01:23:55 +0000 (03:23 +0200)
Here's the spec:
  http://dev.w3.org/csswg/css-cascade/#all-shorthand

Also use it in the reset-to-defaults CSS where a bunch of properties had
been missing.

gtk/gtkcssshorthandpropertyimpl.c
testsuite/reftests/reset-to-defaults.css

index 15cd3596760be0d1ae8a0ea2b6ee1e6658973782..2d2faf80f0f26188d53df177f87d76f4a129f800 100644 (file)
@@ -813,6 +813,15 @@ parse_animation (GtkCssShorthandProperty  *shorthand,
   return TRUE;
 }
 
+static gboolean
+parse_all (GtkCssShorthandProperty  *shorthand,
+           GtkCssValue             **values,
+           GtkCssParser             *parser)
+{
+  _gtk_css_parser_error (parser, "The 'all' property can only be set to 'initial', 'inherit' or 'unset'");
+  return FALSE;
+}
+
 /*** PACKING ***/
 
 static void
@@ -1089,6 +1098,25 @@ _gtk_css_shorthand_property_register (const char                        *name,
   node->query = query_func;
 }
 
+/* NB: return value is transfer: container */
+static const char **
+get_all_subproperties (void)
+{
+  const char **properties;
+  guint i, n;
+
+  n = _gtk_css_style_property_get_n_properties ();
+  properties = g_new (const char *, n + 1);
+  properties[n] = NULL;
+
+  for (i = 0; i < n; i++)
+    {
+      properties[i] = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (i)));
+    }
+
+  return properties;
+}
+
 void
 _gtk_css_shorthand_property_init_properties (void)
 {
@@ -1119,6 +1147,8 @@ _gtk_css_shorthand_property_init_properties (void)
   const char *animation_subproperties[] = { "animation-name", "animation-iteration-count", "animation-duration", "animation-delay", 
                                             "animation-timing-function", "animation-direction", "animation-fill-mode", NULL };
 
+  const char **all_subproperties;
+
   _gtk_css_shorthand_property_register   ("font",
                                           PANGO_TYPE_FONT_DESCRIPTION,
                                           font_subproperties,
@@ -1227,4 +1257,13 @@ _gtk_css_shorthand_property_init_properties (void)
                                           parse_animation,
                                           NULL,
                                           NULL);
+
+  all_subproperties = get_all_subproperties ();
+  _gtk_css_shorthand_property_register   ("all",
+                                          G_TYPE_NONE,
+                                          all_subproperties,
+                                          parse_all,
+                                          NULL,
+                                          NULL);
+  g_free (all_subproperties);
 }
index 8654a5bf0fda283b828231a9e9652072b0696f26..2e72b3d13d59c61bda72a3d311f2c8d5dfbe4bdf 100644 (file)
@@ -7,60 +7,7 @@
  */
 
 * {
-  color: unset;
-  font-size: unset;
-  background-color: unset;
-  font-family: unset;
-  font-style: unset;
-  font-variant: unset;
-  font-weight: unset;
-  text-shadow: unset;
-  icon-shadow: unset;
-  box-shadow: unset;
-  margin-top: unset;
-  margin-left: unset;
-  margin-bottom: unset;
-  margin-right: unset;
-  padding-top: unset;
-  padding-left: unset;
-  padding-bottom: unset;
-  padding-right: unset;
-  border-top-style: unset;
-  border-top-width: unset;
-  border-left-style: unset;
-  border-left-width: unset;
-  border-bottom-style: unset;
-  border-bottom-width: unset;
-  border-right-style: unset;
-  border-right-width: unset;
-  border-top-left-radius: unset;
-  border-top-right-radius: unset;
-  border-bottom-right-radius: unset;
-  border-bottom-left-radius: unset;
-  outline-style: unset;
-  outline-width: unset;
-  outline-offset: unset;
-  background-clip: unset;
-  background-origin: unset;
-  background-size: unset;
-  background-position: unset;
-  border-top-color: unset;
-  border-right-color: unset;
-  border-bottom-color: unset;
-  border-left-color: unset;
-  outline-color:  unset;
-  background-repeat: unset;
-  background-image: unset;
-  border-image-source: unset;
-  border-image-repeat: unset;
-  border-image-slice: unset;
-  border-image-width: unset;
-  transition-property: unset;
-  transition-duration: unset;
-  transition-timing-function: unset;
-  transition-delay: unset;
-  engine: unset;
-  gtk-key-bindings: unset;
+  all: unset;
 
   -GtkWidget-focus-line-width: 0;
   -GtkWidget-focus-padding: 0;